
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.ExceptionType;
import cn.edu.scau.cmi.hombio.domain.ExceptionTypeEmployee;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class ExceptionTypeEmployeeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected ExceptionTypeEmployeeService service;

	/**
	 * Instantiates a new ExceptionTypeEmployeeServiceTest.
	 *
	 */
	public ExceptionTypeEmployeeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveExceptionTypeEmployeeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveExceptionTypeEmployeeEmployee 
		Integer id = 0;
		Employee related_employee = new cn.edu.scau.cmi.hombio.domain.Employee();
		ExceptionTypeEmployee response = null;
		response = service.saveExceptionTypeEmployeeEmployee(id, related_employee);
		// TODO: JUnit - Add assertions to test outputs of operation: saveExceptionTypeEmployeeEmployee
	}

	/**
	 * Operation Unit Test
	* Return a count of all ExceptionTypeEmployee entity
	* 
	 */
	@Test
	public void countExceptionTypeEmployees() {
		Integer response = null;
		response = service.countExceptionTypeEmployees();
		// TODO: JUnit - Add assertions to test outputs of operation: countExceptionTypeEmployees
	}

	/**
	 * Operation Unit Test
	* Return all ExceptionTypeEmployee entity
	* 
	 */
	@Test
	public void findAllExceptionTypeEmployees() {
		// TODO: JUnit - Populate test inputs for operation: findAllExceptionTypeEmployees 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<ExceptionTypeEmployee> response = null;
		response = service.findAllExceptionTypeEmployees(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllExceptionTypeEmployees
	}

	/**
	 * Operation Unit Test
	* Save an existing ExceptionTypeEmployee entity
	* 
	 */
	@Test
	public void saveExceptionTypeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveExceptionTypeEmployee 
		ExceptionTypeEmployee exceptiontypeemployee = new cn.edu.scau.cmi.hombio.domain.ExceptionTypeEmployee();
		service.saveExceptionTypeEmployee(exceptiontypeemployee);
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteExceptionTypeEmployeeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteExceptionTypeEmployeeEmployee 
		Integer exceptiontypeemployee_id = 0;
		Integer related_employee_id = 0;
		ExceptionTypeEmployee response = null;
		response = service.deleteExceptionTypeEmployeeEmployee(exceptiontypeemployee_id, related_employee_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteExceptionTypeEmployeeEmployee
	}

	/**
	 * Operation Unit Test
	* Load an existing ExceptionTypeEmployee entity
	* 
	 */
	@Test
	public void loadExceptionTypeEmployees() {
		Set<ExceptionTypeEmployee> response = null;
		response = service.loadExceptionTypeEmployees();
		// TODO: JUnit - Add assertions to test outputs of operation: loadExceptionTypeEmployees
	}

	/**
	 * Operation Unit Test
	* Save an existing ExceptionType entity
	* 
	 */
	@Test
	public void saveExceptionTypeEmployeeExceptionType() {
		// TODO: JUnit - Populate test inputs for operation: saveExceptionTypeEmployeeExceptionType 
		Integer id_1 = 0;
		ExceptionType related_exceptiontype = new cn.edu.scau.cmi.hombio.domain.ExceptionType();
		ExceptionTypeEmployee response = null;
		response = service.saveExceptionTypeEmployeeExceptionType(id_1, related_exceptiontype);
		// TODO: JUnit - Add assertions to test outputs of operation: saveExceptionTypeEmployeeExceptionType
	}

	/**
	 * Operation Unit Test
	* Delete an existing ExceptionTypeEmployee entity
	* 
	 */
	@Test
	public void deleteExceptionTypeEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteExceptionTypeEmployee 
		ExceptionTypeEmployee exceptiontypeemployee_1 = new cn.edu.scau.cmi.hombio.domain.ExceptionTypeEmployee();
		service.deleteExceptionTypeEmployee(exceptiontypeemployee_1);
	}

	/**
	 * Operation Unit Test
	* Delete an existing ExceptionType entity
	* 
	 */
	@Test
	public void deleteExceptionTypeEmployeeExceptionType() {
		// TODO: JUnit - Populate test inputs for operation: deleteExceptionTypeEmployeeExceptionType 
		Integer exceptiontypeemployee_id_1 = 0;
		Integer related_exceptiontype_id = 0;
		ExceptionTypeEmployee response = null;
		response = service.deleteExceptionTypeEmployeeExceptionType(exceptiontypeemployee_id_1, related_exceptiontype_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteExceptionTypeEmployeeExceptionType
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findExceptionTypeEmployeeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findExceptionTypeEmployeeByPrimaryKey 
		Integer id_2 = 0;
		ExceptionTypeEmployee response = null;
		response = service.findExceptionTypeEmployeeByPrimaryKey(id_2);
		// TODO: JUnit - Add assertions to test outputs of operation: findExceptionTypeEmployeeByPrimaryKey
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
